<script setup lang="ts">
import {ref, onMounted} from "vue";
import useStore from "../../modules/store/evaluate"
import {ElMessageBox} from "element-plus";
const store = useStore()
// 控制对话框的显示与隐藏的开关
// 定义了一个类型判定
interface User {
  key: number
  name: string
  num: number
  price: number
  style: string
}
const handleEdit = (index: number, row: User) => {
  console.log(index, row)
  store.editA('审核通过', row.key)
}
const handleDelete = (index: number, row: User) => {
  console.log(index, row)
  store.filterB(row.key)
}
const handleSelectionChange = (val:any)=>{
  const keyArr:any = [];
  val.forEach((item:any)=>{
    keyArr.push(item.key)
  })
  store.Replace(keyArr)
}
// 渲染完成时发送一个请求
onMounted(()=>{
  console.log(store)
  store.http()
  // console.log(store.list)
});
</script>

<template>
  <el-table :data="store.searchList"
            max-height="250"
            @selection-change="handleSelectionChange"
            style="width: 100%;margin: 30px 0">
    <el-table-column type="selection" width="55"/>
    <el-table-column label="员工编号" width="150">
      <template #default="scope">
        {{scope.row.key}}
      </template>
    </el-table-column>
    <el-table-column label="评价内容" width="200">
      <template #default="scope">
        {{scope.row.content}}
      </template>
    </el-table-column>
    <el-table-column label="商品名称" width="250">
      <template #default="scope">
        {{scope.row.name}}
      </template>
    </el-table-column>
    <el-table-column label="审核状态" width="200">
      <template #default="scope">
        {{scope.row.state}}
      </template>
    </el-table-column>
    <el-table-column label="会员" width="250">
      <template #default="scope">
        {{scope.row.member}}
      </template>
    </el-table-column>
    <el-table-column label="发布时间" width="250">
      <template #default="scope">
        {{scope.row.time}}
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template #default="scope">
        <el-button size="small" class="buttonText" link type="primary" @click="handleEdit(scope.$index, scope.row)"
        >审核</el-button>
        <el-button
            size="small"
            class="buttonText"
            link
            type="primary"
            @click="handleDelete(scope.$index, scope.row)"
        >删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<style scoped lang="scss">

</style>
